<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let p = new Promise((resolve, reject)=>{
            // 1. resolve
            // 2. reject
            // 3. throw 123;  pending --> rejected  throw的内容，就是promise失败的结果值
            // throw 5555;

            // 执行器函数中，return没用，改变不了promise的状态
            // return 123;


            // 异步改变状态
            setTimeout(()=>{
                // 1.
                // resolve('ok'); // pending  -> fulfilled
                // 2. 
                // reject('error123123');

                // 3. throw 在异步回调中无法改变promise为失败的状态
                throw 123123;
            },2000)
        })
        console.log(p);
        p.then(value=>{
            console.log('成功： ',value);
        },reason=>{
            console.log('失败： ', reason);
        })
    </script>
</body>
</html>